package com.xiaow.android.ebook.mvc.controller.pools;

import java.util.concurrent.Callable;

import com.xiaow.android.ebook.mvc.command.ICommand;

public class CommandThread implements Callable<Integer> {

    private ICommand cmd = null;

    private boolean isRunning = false;

    public CommandThread(ICommand cmd) {
        this.cmd = cmd;
    }

    public void run() {
        
    }

    public ICommand getCmd() {
        return cmd;
    }

    public boolean setCmd(ICommand cmd) {
        if (isRunning)
            return false;
        this.cmd = cmd;
        return true;
    }

	@Override
	public Integer call() throws Exception {
		isRunning = true;   
        cmd.execute();
        isRunning = false;
		return 0;
	}

}
